import { NestFactory } from '@nestjs/core';
import { Logger } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { ProcessorModule } from './processor.module';
// @app
import { WinstonLogger } from '@app/common';
// logger
import { WinstonModule } from 'nest-winston';

async function bootstrap() {
  // create
  const app = await NestFactory.create(ProcessorModule, {
    logger: WinstonModule.createLogger({
      instance: WinstonLogger,
    }),
  });
  // config
  const configService = app.get(ConfigService);
  // 端口和地址
  await app.listen(
    configService.get<number>('processor.port', 9530),
    configService.get<string>('processor.host', '0.0.0.0'),
    async () => {
      Logger.log('Starting on env: ' + configService.get<string>('app.env'));
      Logger.log(`listening on ${await app.getUrl()}`);
    },
  );
}
bootstrap();
